package org.cli.admin.command.impl;

import org.cli.admin.command.AbstractCommand;
import org.cli.admin.command.Command;
import org.cli.admin.init.Application;
import org.fusesource.jansi.Ansi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;

import static org.fusesource.jansi.Ansi.ansi;

@Command(name = "exit", aliases = {"quit", "stop", "x", "q"}, global = true)
public class ExitCommand extends AbstractCommand{
	
	private static final Logger logger = LoggerFactory.getLogger(ExitCommand.class);

	@Inject
	private Application application;
	
	@Override
	public void execute() {
		logger.info("User requested exit...");
        // Stopping the application
        application.stop();

        System.out.println(ansi().a(Ansi.Attribute.INTENSITY_BOLD).fg(Ansi.Color.WHITE).a("Good bye!").reset());
        System.exit(0);

	}

}
